<script type="text/javascript" language="javascript" charset="utf-8">
$(".header-con li a").removeClass("open-menu");
$(".header-con li #finance").addClass("open-menu");
</script>
<div class="boxed clearfix">
  <div class="mask cos-add">
  </div>
  <div class="common-tit">
    <h2>固定成本设置</h2>
    <span>财务管理 > 固定成本设置</span>
    <%= link_to "添加", new_admin_fixed_cost_path, remote: true, class: 'add-staff' %>
  </div>
  <div class="chief">
    <h3>团队指标</h3>
  </div>
  <div class="indi-con tut">
    <div class="scrollbox">
      <table>
        <thead>
          <tr>
            <th class="fina-name">名称</th>
            <th class="fina-clnum">费用(元)</th>
            <th class="fina-money">周期</th>
            <th class="fina-money">分担分店</th>
            <th class="mar-operation">
              <div>
                <em>操作</em>
              </div>
            </th>
          </tr>
        </thead>
        <tbody>
          <% @fixed_costs.each do |fc| %>
          <tr>
            <td><%= fc.name %></td>
            <td><%= fc.amount %></td>
            <td><%= "#{fc.cycle}月" %></td>
            <td><%= fc.studios.map(&:name).join(",") %></td>
            <td class="sta-operation">
              <div>
                <em>[</em>
                <span>
                  <%= link_to "编辑", edit_admin_fixed_cost_path(fc), remote: true%>
                </span>
                <em>]</em>
              </div>
            </td>
          </tr>
          <%end%>
        </tbody>
      </table>
    <div class="apple_pagination">
      <%= will_paginate @fixed_costs, :container => false %>
    </div>
    </div>
  </div>
</div>
<script src="/assets/js/jquery-1.12.3.js"></script>
<script src="/assets/js/common-list.js"></script>
<script>
$("#addCost").on("click", function() {
  $(".cos-add").css({
    "display" : "block"
  });
});

$(".f-edit").on("click", function() {
  $(".cos-add").css({
    "display" : "block"
  });
});
/* 多选下拉列表 */
function MultipleDown() {
$(".mul-downbtn").on("click", function() {
  if (!$(this).next().hasClass("menuopen")) {
    $(this).next().addClass("menuopen");
  }
});
$(".multiselect-down li").on("click", function() {
  if ($(this).hasClass("mul-select")) {
    $(this).removeClass("mul-select");
  } else {
    $(this).addClass("mul-select");
  };
});
$(".mul-confirm").on("click", function() {
  var arr = [];
  for (var i = 0; i < $(this).parent().parent().find(".mul-select").length; i++) {
    arr.push($($(this).parent().parent().find(".mul-select")[i]).children("strong").attr("data_id"));
  };
  $("#fixed_cost_studio_ids").val(arr);
  console.log(arr);
  // 在此处加入ajax 提交数据
  $(this).parent().parent().removeClass("menuopen");
})
$(".mul-cancel").on("click", function() {
  $(this).parent().parent().removeClass("menuopen");
})
$(".mul-downbtn input").on('input',function(e){
  if ($(this).val() != "") {
    // console.log($(this).val());
    $(".multiselect-down li").addClass("mul-hide");
    $($(".multiselect-down li:contains(" + $(this).val() + ")")).removeClass("mul-hide");
  } else {
    $(".multiselect-down li").removeClass("mul-hide");
  }
});  
}
</script>
